#include "utility.hpp"

#include "cmd_err_code.hpp"

#include "gateway_cmd.hpp"

namespace cmd
{
	void CSLoginReq::serialize(Streamer & streamer)
	{
		CSHead::serialize(streamer);
		streamer & _passwd;
	}

	const std::string CSLoginReq::to_string() const
	{
		std::ostringstream oss;
		oss << CSHead::to_string()
			<< " body: {passwd: " << _passwd
			<< "}";
		return oss.str();
	}
	
	void SCLoginRes::serialize(Streamer & streamer)
	{
		SCHead::serialize(streamer);
		streamer & _role_b;
	}

	const std::string SCLoginRes::to_string() const
	{
		std::ostringstream oss;
		oss << SCHead::to_string()
			<< " body: {role_b: " << _role_b.to_string()
			<< "}";
		return oss.str();
	}

	void SCGetAreaRes::serialize(Streamer & streamer)
	{
		SCHead::serialize(streamer);
		streamer & _area_list;
	}

	const std::string SCGetAreaRes::to_string() const
	{
		std::ostringstream oss;
		oss << SCHead::to_string()
			<< " body: {area: " << Utility::vec_to_string(_area_list)
			<< "}";
		return oss.str();
	}

	void CSGetRoomReq::serialize(Streamer & streamer)
	{
		CSHead::serialize(streamer);
		streamer & _area_id;
	}

	const std::string CSGetRoomReq::to_string() const
	{
		std::ostringstream oss;
		oss << CSHead::to_string()
			<< " body: {area_id: " << (int)_area_id
			<< "}";
		return oss.str();
	}

	void SCGetRoomRes::serialize(Streamer & streamer)
	{
		SCHead::serialize(streamer);
		streamer & _area_id
				 & _room_list;
	}

	const std::string SCGetRoomRes::to_string() const
	{
		std::ostringstream oss;
		oss << "body: {area_id: " << (int)_area_id
			<< ", room : " << Utility::vec_to_string(_room_list)
			<< "}";
		return oss.str();
	}

	void CSGetTableReq::serialize(Streamer & streamer)
	{
		CSHead::serialize(streamer);
		streamer & _room_id;
	}

	const std::string CSGetTableReq::to_string() const
	{
		std::ostringstream oss;
		oss << CSHead::to_string()
			<< " body: {room_id: " << _room_id.to_string()
			<< "}";
		return oss.str();
	}

	void SCGetTableRes::serialize(Streamer & streamer)
	{
		SCHead::serialize(streamer);

		streamer & _room_id
			     & _online
				 & _table_list;
	}

	const std::string SCGetTableRes::to_string() const
	{
		std::ostringstream oss;
		oss << SCHead::to_string()
			<< " body: {room_id: " << _room_id.to_string()
			<< ", online: " << (int)_online
			<< ", table list size: " << _table_list.size()
			<< "}";
		return oss.str();
	}

	void SSReportAreaReq::serialize(Streamer & streamer)
	{
		SSHead::serialize(streamer);
		streamer & _svr_id
			     & _area_id
			     & _room_capacity
			     & _room_list;
	}

	const std::string SSReportAreaReq::to_string() const
	{
		std::ostringstream oss;
		oss << SSHead::to_string()
			<< " body: {svr_id: " << (int)_svr_id
			<< ", area_id: " << (int)_area_id
			<< ", room_capacity: " << (int)_room_capacity
			<< ", room_num: " << (int)_room_list.size()
			<< "}";
		return oss.str();
	}
	
	void SCNotifyReady::serialize(Streamer & streamer)
	{
		SCNotify::serialize(streamer);
		streamer & _rid;
	}

	const std::string SCNotifyReady::to_string() const
	{
		std::ostringstream oss;
		oss << SCNotify::to_string()
			<< " body: {rid: " << _rid
			<< "}";
		return oss.str();
	}
};


